home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-16 | 18.1 KB | 572 lines | [TEXT/KAHL] |
- $$Loop ModalDialogs
- $$Message MM Modal Dialog, mm:mmD_$Worksheet.name$.cp
-
- $$File mm:mmD_$Worksheet.name$.cp
- /* mmD_$Worksheet.name$ Handle this dialog */
- /* $CopyRight$ */
-
- /* File name: mmD_$Worksheet.name$.c
- Function: Handle this modal dialog.
-
- This dialog is called when:
-
- History: $Date$ Original by $Author$
-
- */
-
- #include "mmCommon$Prototype.name$.h" /* Common */
- #include "Common$Prototype.name$.h" /* Common */
-
- /* ======================================================= */
- /* ======================================================= */
-
- /* Routine: Init */
- /* Purpose: Initialize the modal dialog, globals and call users routine */
-
- void CmmD$Worksheet.name$::Init()
- {
-
-
- inherited::Init();
-
- $$Loop Control.type = Button
- this->Enable_$Control.name$ = $Control.Active$; /* Button */
- $$EndLoop
- $$Loop Control.type = HotRect
- $$if Control.HotSpot
- this->Enable_$Control.name$ = $Control.Active$; /* HotSpot */
- $$endif
- $$EndLoop
- $$Loop Control.type = Checkbox
- this->Enable_$Control.name$ = $Control.Active$; /* Checkbox */
- $$if Control.Selected
- this->Value_$Control.name$ = 1;
- $$endif
- $$if Control.Unselected
- this->Value_$Control.name$ = 0;
- $$endif
- $$EndLoop
- $$Loop Control.type = Radio
- this->Enable_$Control.name$ = $Control.Active$; /* Radio */
- $$if Control.Selected
- this->Value_$Control.name$ = 1;
- $$endif
- $$if Control.Unselected
- this->Value_$Control.name$ = 0;
- $$endif
- $$EndLoop
- $$Loop Control.type = ScrollBar
- this->Enable_$Control.name$ = $Control.Active$; /* ScrollBar */
- this->Value_$Control.name$ = $Control.ValueScroll$;
- $$EndLoop
- $$Loop Control.type = Icon
- this->Enable_$Control.name$ = $Control.Active$; /* Icon button */
- $$EndLoop
- $$Loop Control.type = Sicn
- this->Enable_$Control.name$ = $Control.Active$; /* Sicn button */
- $$EndLoop
- $$Loop Control.type = Picture
- $$if Control.NonGraphic
- this->Enable_$Control.name$ = $Control.Active$; /* Picture button */
- $$endif
- $$EndLoop
- $$Loop Control.type = UButton
- this->Enable_$Control.name$ = $Control.Active$; /* Plugin button */
- $$EndLoop
- $$Loop Control.type = UToggle
- this->Enable_$Control.name$ = $Control.Active$; /* Plugin toggle */
- $$if Control.Selected
- this->Value_$Control.name$ = 1;
- $$endif
- $$if Control.Unselected
- this->Value_$Control.name$ = 0;
- $$endif
- $$EndLoop
- $$Loop Control.type = UGauge
- this->Enable_$Control.name$ = $Control.Active$; /* Plugin gauge */
- this->Value_$Control.name$ = $Control.ValueScroll$;
- $$EndLoop
- $$Loop Control.type = Popup
- this->Enable_$Control.name$ = $Control.Active$; /* Popup menu */
- this->Value_$Control.name$ = $Control.SelectedID$;
- $$EndLoop
- $$Loop Control.type = Palette
- this->Enable_$Control.name$ = $Control.Active$; /* Palette */
- this->Value_$Control.name$ = $Control.ValueScroll$;
- $$EndLoop
- $$Loop Control.type = List
- this->List_$Control.name$ = nil; /* List */
- SetRect(&this->ListRect_$Control.name$,$Control.LeftPosition$,$Control.TopPosition$,$Control.RightPosition$,$Control.BottomPosition$); /* left,top,right,bottom */
- $$EndLoop
- $$Loop Control.type = EditText
- this->TE_$Control.name$ = nil; /* Edit Text */
- SetRect(&this->TERect_$Control.name$,$Control.LeftPosition$,$Control.TopPosition$,$Control.RightPosition$,$Control.BottomPosition$); /* left,top,right,bottom */
- GetIndString(this->TEStr_$Control.name$,sResD_$Control.name$,1);/* ...Edit text, default value */
- $$EndLoop
-
- }
-
- /* ======================================================= */
-
- void CmmD$Worksheet.name$::FilterMouseDown(DialogPtr theDialog,EventRecord *theEvent,
- short *itemHit,Point MyPt)
- {
- Rect tempRect; /* Temporary rectangle */
- short DType; /* Type of dialog item */
- short code;
- Handle DItem; /* Handle to the dialog item */
- ControlHandle CItem; /* Control handle */
-
-
- inherited::FilterMouseDown(theDialog,theEvent,itemHit,MyPt);
-
- $$Loop Control.type = List
- if (PtInRect(MyPt,&this->ListRect_$Control.name$))
- ClickInTheList(MyPt,theEvent->modifiers,this->List_$Control.name$,
- $Control.TextSize$,$Control.TextFont$,$Control.TextStyle$,true);
-
- $$EndLoop
- $$Loop Control.type = ScrollBar
- GetDItem (theDialog ,ResD_$Control.name$, &DType, &DItem, &tempRect);/* Get the item */
- if (PtInRect(MyPt,&tempRect))
- {
- CItem = (ControlHandle)DItem; /* Make it a controlhandle */
- code = TestControl(CItem,MyPt); /* Get where in the Scrollbar we were pressed */
- HandleWScrollBar(MyPt,code,$Control.StepScroll$,$Control.PageScroll$,CItem);/* Handle the scrollbar */
- }
-
- $$EndLoop
- $$Loop Control.type = UGauge
- GetDItem (theDialog ,ResD_$Control.name$, &DType, &DItem, &tempRect);/* Get the item */
- if (PtInRect(MyPt,&tempRect))
- {
- CItem = (ControlHandle)DItem; /* Make it a controlhandle */
- code = TestControl(CItem,MyPt); /* Get where in the gauge we were pressed */
- HandleWScrollBar(MyPt,code,$Control.StepScroll$,$Control.PageScroll$,CItem);/* Handle the scrollbar */
- }
-
- $$EndLoop
- }
-
- /* ======================================================= */
-
- /* Routine: Refresh */
- /* Purpose: Refresh the dialogs non-controls */
-
- void CmmD$Worksheet.name$::Refresh()
- {
- Rect rTempRect; /* Temp rectangle used for drawing */
- short DType; /* Type of dialog item */
- Handle DItem; /* Handle to the dialog item */
- ControlHandle CItem; /* Control handle */
- RGBColor Saved_ForeColor; /* Save colors */
- RGBColor Saved_BackColor; /* Save colors */
-
-
- SetPort(this->theWindow); /* Point to our dialog window */
- rTempRect = tempRect; /* Save the current contents of tempRect */
- if (Has.ColorQD) /* See if color QuickDraw is around */
- {
- GetForeColor(&Saved_ForeColor); /* Save the fore color */
- GetBackColor(&Saved_BackColor); /* Save the back color */
-
- RGBForeColor(&Black_ForeColor); /* Set the fore color to Black */
- RGBBackColor(&White_BackColor); /* Set the back color to White */
- }
-
- $$Loop Control.type = Button
- $$if Control.Default
- /* This is the default selection, when RETURN is pressed. */
- HiliteDefaultButton(this->theWindow,ResD_$Control.name$);
-
- $$endif Control.Default
- $$EndLoop Control.type
- $$Loop Control.type = Line
- /* Draw a line, $Control.FullName$ */
- $$if Control.GrayLine
- PenPat(qd.gray); /* Set the gray pen pattern */
- $$endif Control.GrayLine
- $$if Control.LineWidth ! 1
- PenSize($Control.LineWidth$,$Control.LineWidth$);
- $$endif Control.LineWidth
- MoveTo($Control.LeftPosition$,$Control.TopPosition$); /* Horz,vert, Move to starting position */
- LineTo($Control.RightPosition$,$Control.BottomPosition$); /* Horz,vert, Draw to the ending position */
- $$if Control.LineWidth ! 1
- PenSize(1,1);
- $$endif Control.LineWidth
- $$if Control.GrayLine
- PenPat(qd.black); /* Back to default pen pattern */
- $$endif Control.GrayLine
-
- $$EndLoop
- $$Loop Control.type = StaticText
- $$if Control.SpecialText
- /* Draw static text */
- $$if Control.TextColor ! Black
- if (Has.ColorQD) /* See if color QuickDraw is around */
- {
- DrawingColor.red = 0x$Control.RedTextColor$;
- DrawingColor.green = 0x$Control.GreenTextColor$;
- DrawingColor.blue = 0x$Control.BlueTextColor$;
- RGBForeColor(&DrawingColor); /* Set the fore color */
- RGBBackColor(&Saved_BackColor); /* Set the back color */
- }
- $$endif Control.TextColor
- $$if Control.MultipleLine
- SetRect(&tempRect,$Control.LeftPosition$,$Control.TopPosition$,$Control.RightPosition$,$Control.BottomPosition$);
- DrawStaticTextBox(sResD_$Control.name$,&tempRect,$Control.TextAlignment$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$);
- $$endif Control.MultipleLine
- $$if Control.SingleLine
- DrawStaticLine(sResD_$Control.name$,$Control.LeftPosition$,$Control.TopPosition$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$);
- $$endif Control.SingleLine
- $$if Control.TextColor ! Black
- if (Has.ColorQD) /* See if color QuickDraw is around */
- {
- RGBForeColor(&Black_ForeColor); /* Set the fore color */
- RGBBackColor(&White_BackColor); /* Set the back color */
- }
- $$endif Control.TextColor
-
- $$endif Control.SpecialText
- $$EndLoop
- $$Loop Control.type = List
- UpdateTheList(this->theWindow->visRgn,this->List_$Control.name$,
- &this->ListRect_$Control.name$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$,true);
-
- $$EndLoop
- TextSize(12);
- TextFont(systemFont); /* Select the Font that we want */
- TextFace(0); /* Select the style that we want */
-
- if (Has.ColorQD) /* See if color QuickDraw is around */
- {
- RGBForeColor(&Saved_ForeColor); /* Restore the fore color */
- RGBBackColor(&Saved_BackColor); /* Restore the back color */
- }
- }
-
- /* ======================================================= */
-
- /* Routine: BringUpDialog */
- /* Purpose: Modal dialog */
-
- void CmmD$Worksheet.name$::BringUpDialog()
- {
- Rect tempRect; /* Temporary rectangle */
- short DType; /* Type of dialog item */
- short Index; /* For looping */
- Handle DItem; /* Handle to the dialog item */
- ControlHandle CItem; /* Control handle */
- ControlHandle CTempItem; /* Control handle */
- Str255 sTemp; /* Get text entered, temp holding */
- short itemHit; /* Get selection */
- short temp; /* Get selection, temp holding */
- short theSelection; /* For Palettes */
- long theLong,LTemp2; /* For Hotspot setup */
- short theRow; /* This is used to define the row used in a list */
- GrafPtr SavedPort; /* Previous grafport */
- Point MyPt;
- DialogPtr theDialog;
- #if defined(powerc) || defined(__powerc)
- ModalFilterUPP theFilter;
- #endif
-
-
- #if defined(powerc) || defined(__powerc)
- theFilter = NewModalFilterProc(theModalDialogFilter);
- #endif
- gCurrentModalDialog = g$Worksheet.name$;
-
- GetPort(&SavedPort); /* Get the previous grafport */
- HoldOffUserEvents = true; /* Hold off the user events */
-
- this->theWindow = GetNewDialog(ResD_$Worksheet.name$,nil,(WindowPtr)-1);/* Bring in the dialog resource */
- theDialog = this->theWindow;
- SetPort(theDialog); /* Prepare to add conditional text */
-
- $$if Worksheet.Center
- tempRect = theDialog->portRect; /* Get the windows position and size */
- $$if Worksheet.CenterHorz
- tempRect.left = ((screenRect.bounds.right - screenRect.bounds.left) - (tempRect.right - tempRect.left)) / 2; /* Center Horz */
- $$endif Worksheet.CenterHorz
- $$if Worksheet.CenterVert
- tempRect.top = ((screenRect.bounds.bottom - screenRect.bounds.top) - (tempRect.bottom - tempRect.top)) / 3; /* 1/3 vert */
- if (tempRect.top < 40) /* Keep below the menu bar */
- tempRect.top = 40;
- $$endif Worksheet.CenterVert
- MoveWindow(theDialog,tempRect.left,tempRect.top,true);
-
- $$endif
- $$Loop Control.type = Button
- /* Button */
- SetupNormalControl(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,0);
-
- $$EndLoop Button
- $$Loop Control.type = Checkbox
- /* Checkbox */
- SetupNormalControl(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- this->Value_$Control.name$);
-
- $$EndLoop Checkbox
- $$Loop Control.type = Radio
- /* Radio button */
- SetupNormalControl(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- this->Value_$Control.name$);
-
- $$EndLoop Radio
- $$Loop Control.type = List
- /* Make a List */
- Make_A_List(&this->List_$Control.name$,&this->ListRect_$Control.name$,
- theDialog,sResD_$Control.name$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$,true);
-
- $$EndLoop
- $$Loop Control.type = HotRect
- /* Draw a Hotspot or Rectangle */
- SetupHotSpot(theDialog,ResD_$Control.name$,$Control.MakeHotSpot$,$Control.LineWidth$,
- $Control.ShadowWidth$,sResD_$Control.name$,this->Enable_$Control.name$);
-
- $$EndLoop
- $$Loop Control.type = EditText
- GetDItem(theDialog,ResD_$Control.name$,&DType,&DItem,&tempRect);/* Get the item handle */
- GetIndString(sTemp,sResD_$Control.name$,1); /* ...Edit text, default value */
- SetIText(DItem,sTemp); /* Set the default text string */
- SelIText(theDialog,ResD_$Control.name$,0,300);
-
- $$EndLoop
- $$Loop Control.type = Popup
- SetupPopupMenu(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- mResD_$Control.name$,this->Value_$Control.name$);
-
- $$EndLoop
- $$Loop Control.type = Picture
- $$if Control.NonGraphic
- /* Draw a picture */
- LTemp = ResD_N_$Control.name$; /* Picture ID and resize flag */
- $$if Control.ClipPicture
- LTemp = 0x00010000 | LTemp;
- $$endif Control.ClipPicture
- SetupTheItem(theDialog,ResD_$Control.name$,true,true,
- this->Enable_$Control.name$,false,&tempRect,LTemp,0);/* Setup the Picture button */
-
- $$endif Control.NonGraphic
- $$EndLoop
- $$Loop Control.type = Palette
- /* Draw a Palette */
- SetupPalette(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- $Control.NumRows$,$Control.NumColumns$,ResD_N_$Control.name$,$Control.HMethod$);
-
- $$EndLoop
- $$Loop Control.type = Icon
- $$if Control.NonGraphic
- /* Draw an Icon button */
- SetupIconSicn(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- ResD_N_$Control.name$,ResD_H_$Control.name$);
-
- $$endif Control.NonGraphic
- $$EndLoop
- $$Loop Control.type = Sicn
- /* Draw an Sicn */
- $$if Control.Graphic
- SetupIconSicn(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- ResD_N_$Control.name$,ResD_N_$Control.name$);
- $$endif Control.Graphic
- $$if Control.NonGraphic
- SetupIconSicn(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- ResD_N_$Control.name$,ResD_H_$Control.name$);
- $$endif Control.NonGraphic
-
- $$EndLoop
- $$Loop Control.type = UButton
- SetupPlugin(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- ResD_N_$Control.name$,ResD_H_$Control.name$,sResD_$Control.name$);
-
- $$EndLoop
- $$Loop Control.type = UToggle
- SetupPlugin(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- ResD_N_$Control.name$,ResD_H_$Control.name$,sResD_$Control.name$);
-
- $$EndLoop
- $$Loop Control.type = UGauge
- SetupPlugin(theDialog,ResD_$Control.name$,this->Enable_$Control.name$,
- ResD_N_$Control.name$,ResD_H_$Control.name$,sResD_$Control.name$);
- SetupMinMaxValue(theDialog,ResD_$Control.name$,$Control.MinScroll$,$Control.MaxScroll$,this->Value_$Control.name$);
-
- $$EndLoop
- $$Loop Control.type = ScrollBar
- SetupTheItem(theDialog,ResD_$Control.name$,true,true,
- this->Enable_$Control.name$,true,&tempRect,0,0);
- SetupMinMaxValue(theDialog,ResD_$Control.name$,$Control.MinScroll$,$Control.MaxScroll$,this->Value_$Control.name$);
-
- $$EndLoop
-
- this->ExitDialog = false; /* Do not exit dialog handle loop yet */
-
- $$Link Worksheet.Open
-
- this->ExtraSetup(); /* Call user Dialog setup routine */
-
- ShowWindow(theDialog); /* Open a dialog box */
- SelectWindow(theDialog); /* Lets see it */
-
- do /* Start of dialog handle loop */
- {
- #if defined(powerc) || defined(__powerc)
- ModalDialog(theFilter,&itemHit); /* Wait until an item is hit */
- #else
- ModalDialog((ModalFilterProcPtr)&theModalDialogFilter,&itemHit); /* Wait until an item is hit */
- #endif
-
- this->DoItemHit(&itemHit,&this->ExitDialog); /* Let user handle the item hit */
-
- if (itemHit == 32000) /* Check for update */
- {
- this->Refresh(); /* Draw any Lists, lines, or rectangles */
- EndUpdate(theDialog); /* End of the update */
- }
- else if (itemHit > 0)
- {
- GetDItem(theDialog,itemHit,&DType,&DItem,&tempRect); /* Get item information */
- CItem = (ControlHandle)DItem; /* Get the control handle */
- }
-
- $$Loop Control.type = Button
- if (itemHit == ResD_$Control.name$) /* Handle the Button being pressed */
- {
- $$Link Control.Select
- $$if Control.ExitDialog
- this->ExitDialog = true; /* Close this dialog, exit */
- $$endif Control.ExitDialog
- }
-
- $$EndLoop Control.type
- $$Loop Control.type = Checkbox
- if (itemHit == ResD_$Control.name$) /* Handle the checkbox being pressed */
- {
- temp = GetCtlValue(CItem); /* Get the current Checkbox value */
- SetCtlValue(CItem, (temp + 1) & 1); /* Toggle the value to the opposite */
- this->Value_$Control.name$ = GetCtlValue(CItem); /* Get the current Checkbox value */
- $$if Control.HasLinks
- if (this->Value_$Control.name$ == 0)
- {
- $$Link Control.Deselect
- }
- else
- {
- $$Link Control.Select
- }
- $$endif
- }
-
- $$EndLoop Control.type
- $$Loop Control.type = UButton
- $$if Control.HasLinks
- if (itemHit == ResD_$Control.name$) /* Handle the Button being pressed */
- {
- $$Link Control.Select
- }
-
- $$endif
- $$EndLoop Control.type
- $$Loop Control.type = UToggle
- if (itemHit == ResD_$Control.name$) /* Handle the checkbox being pressed */
- {
- temp = GetCtlValue(CItem); /* Get the current Checkbox value */
- SetCtlValue(CItem, (temp + 1) & 1); /* Toggle the value to the opposite */
- this->Value_$Control.name$ = GetCtlValue(CItem); /* Get the current Checkbox value */
- $$if Control.HasLinks
- if (this->Value_$Control.name$ == 0)
- {
- $$Link Control.Deselect
- }
- else
- {
- $$Link Control.Select
- }
- $$endif
- }
-
- $$EndLoop Control.type
- $$Loop Control.type = Radio
- if (itemHit == ResD_$Control.name$) /* Handle the Radio being pressed */
- {
- SetCtlValue(CItem,1);
- this->Value_$Control.name$ = 1; /* Set the current Radio value */
-
- $$Loop RadioGroup
- ClearTheRadio(theDialog,ResD_$Control.name$,&this->Value_$Control.name$);
- $$EndLoop RadioGroup
- $$Link Control.Select
- }
-
- $$EndLoop Control.type
- $$Loop Control.type = HotRect
- $$if Control.HotSpot
- $$if Control.HasLinks
- if (itemHit == ResD_$Control.name$) /* Handle the HotSpot being pressed */
- {
- $$Link Control.Select
- }
-
- $$endif
- $$endif Control.HotSpot
- $$EndLoop
- $$Loop Control.type = Popup
- $$EndLoop
- $$Loop Control.type = Picture
- $$if Control.NonGraphic
- $$if Control.HasLinks
- if (itemHit == ResD_$Control.name$) /* Handle the Picture being pressed */
- {
- $$Link Control.Select
- }
-
- $$endif
- $$endif Control.NonGraphic
- $$EndLoop
- $$Loop Control.type = Palette
- $$EndLoop
- $$Loop Control.type = Icon
- $$if Control.NonGraphic
- $$if Control.HasLinks
- if (itemHit == ResD_$Control.name$) /* Handle the Icon being pressed */
- {
- $$Link Control.Select
- }
-
- $$endif
- $$endif Control.NonGraphic
- $$EndLoop
- $$Loop Control.type = Sicn
- $$if Control.NonGraphic
- $$if Control.HasLinks
- if (itemHit == ResD_$Control.name$) /* Handle the Sicn being pressed */
- {
- $$Link Control.Select
- }
-
- $$endif
- $$endif Control.NonGraphic
- $$EndLoop
- }
- while (!this->ExitDialog); /* Handle dialog items until exit selected */
-
- /* Get results after dialog */
-
- this->Exit(); /* Exiting the modal dialog */
-
- $$Link Worksheet.Close
-
- SetPort(SavedPort); /* Restore the previous grafport */
- DisposDialog(theDialog); /* Flush the dialog out of memory */
-
- gCurrentModalDialog = nil;
- HoldOffUserEvents = false; /* Let in the user events */
- }
-
- /* ======================================================= */
- /* ======================================================= */
- $$CloseFile
- $$EndLoop
-
-
-